Gambler's Ruin

Using computer programmes to tackle statistics problems.

The gambler's ruin problem is as follows:
Gambler A and gambler B play a game.
The two gamblers each start with their own set of coins. At each turn they flip one of the coins. If the coin shows heads, gambler A takes a coin from gambler B. If the coin shows tails, gambler B takes a coin from gambler A.
Let there be 100 coins total. Gambler A has N coins and Gambler B has 100 - N coins.

What is the probability that gambler A wins?

This problem can be approached computationally.

Example Run:

The code for this project was written in C++ and is available here.

The programme was run a 1000 times, for N = 50. Gambler A won exactly 49.7% of the time.
What happens if we tweak these figures, say to N = 25?

Interesting ... Gambler A won 24.8% of the time. We can begin to see a pattern forming. The probability that Gambler A wins seems to be given by the number of coins they start with.

Let's try for a few other values of N ...

N Number of Times Gambler A Wins Percentage
1 7 0.7%
5 47 4.7%
10 97 9.7%
20 497 49.7%
75 751 75.2%

As we see, the fraction of coins Gambler A starts with initially determines their chance of winning the game.